package com.jean.com.retrofittest.task;

import com.jean.com.retrofittest.HttpResult;
import com.jean.com.retrofittest.HttpResultFun;
import com.jean.com.retrofittest.entity.AtlasList;

import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;
import rx.Subscriber;

/**
 * Created by jean on 2016/5/11.
 */
public class GetAltasTask extends AbstractTask{
    private AtlasService mAtlasService;
    private Observable<HttpResult<AtlasList>> observable;
    public interface AtlasService {
        @GET("getCircleAppSketchAlbum.do")
        Observable<HttpResult<AtlasList>> getAtlasList(
                @Query("timestamp")
                String timestamp
                ,@Query("version")
                String version
                ,@Query("access_token")
                String access_token
                ,@Query("bi_channel")
                String bi_channel
                ,@Query("mac")
                String mac
                ,@Query("page")
                String page
        );
    }

    public GetAltasTask(String timestamp,String version,String access_token,String bi_channel,String mac,String page){
       observable = mAtlasService.getAtlasList(timestamp,version,access_token,bi_channel,mac,page);
    }

    public void send(Subscriber<AtlasList> subscribers){
        toSubcribe(observable.map(new HttpResultFun<AtlasList>()),subscribers);
    }
    @Override
    public void creatService() {
        mAtlasService = mRetrofit.create(AtlasService.class);
    }

}
